package com.wonder.admin.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wonder.admin.domain.SysPrdIn;
import com.wonder.admin.mapper.SysPrdInDao;
import com.wonder.admin.request.SysRoleRequest;
import com.wonder.admin.service.SysPrdInService;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wonder.common.common.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author sunyf
 * @since 2023-11-13
 */
@Service
public class SysPrdInServiceImpl extends ServiceImpl<SysPrdInDao, SysPrdIn> implements SysPrdInService {

    @Autowired
    private SysPrdInDao sysPrdInDao;

    @Override
    public Map<String,Object> getPage(SysRoleRequest sysRoleRequest) {
        Map<String,Object> dataMap = new HashMap<>();//返回值
        //查询条件
        QueryWrapper<SysPrdIn> wrapper = new QueryWrapper<>();
        Page<SysPrdIn> page = new Page<>(1,2);
        IPage<SysPrdIn> sysPrdInIPage = sysPrdInDao.selectPage(page,wrapper);

        dataMap.put("total",sysPrdInIPage.getTotal());//总条数
        dataMap.put("pages",sysPrdInIPage.getPages());//总页数
        dataMap.put("data",sysPrdInIPage.getRecords());//数据
        return dataMap;
    }

    @Override
    public IPage<SysPrdIn> selectList(SysRoleRequest request, Page<SysPrdIn> page) {
        //查询条件
        QueryWrapper<SysPrdIn> wrapper = new QueryWrapper<>();
        IPage<SysPrdIn> sysPrdInIPage = sysPrdInDao.selectPage(page,wrapper);
        return sysPrdInIPage;
    }

    @Override
    public SysPrdIn getDetail(Long id) {

        return sysPrdInDao.getDetail(id);
    }


}
